// packageF/crowd_activity/children/activity.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    active: {
      type: Number,
      value: 0,
    },
    listData: {
      type: null
    },
    crowdfund_diy_name: {
      type: null,
    },
    fontSizeSetting: {
      type: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    list: ["全部", "进行中", "众筹成功", "众筹失败"],
    index: 0,
    payShow: false,
    // 全部报名人员
    allUserShowList: [],
    allUserpage: 1,
    payId: ''
  },
  observers: {
    active(aval) {
      if (aval) {
        this.setData({
          index: 0
        });
      }
    },
    crowdfund_diy_name: function (name) {
      if (name) {
        this.setData({
          list: ["全部", "进行中", name + "成功", name + "失败"],
        })
      }
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    closePayShow() {
      this.setData({
        payShow: false
      })
    },
    payShowTap(e) {
      let ismore = e.currentTarget.dataset.booleans;
      let id = e.currentTarget.dataset.id;
      if (ismore == 1) {
        console.log(this.data.allUserShowList)
        this.data.allUserpage = this.data.allUserpage + 1;
      } else {
        this.data.payId = id;
      }
      let json = {
        page: this.data.allUserpage,
        activity_member_id: id
      }
      let urlStr = app.getNetAddresss("plugin.crowdfunding.frontend.activity-order.memberRecords");
      app._getNetWork({
        url: urlStr,
        data: json,
        success: (resdata) => {
          let res = resdata.data
          if (res.result == 1) {
            this.setData({
              payShow: true
            })
            if (ismore == 1) {
              if (res.data.data.length > 0) {
                this.setData({
                  ['allUserShowList.data']: this.data.allUserShowList.data.concat(res.data.data)
                })
              }
            } else {
              this.setData({
                allUserShowList: res.data
              })
            }

          }
        },
        fail: function (res) {
          console.log(res);
        }
      })
    },
    toUrl(e) {
      let id = e.currentTarget.dataset.id;
      let aid = e.currentTarget.dataset.aid;
      if (this.data.active == 1) {
        wx.navigateTo({
          url: '/packageF/crowd_activity/goods/goods?id=' + aid,
        })
      } else {
        wx.navigateTo({
          url: '/packageF/crowd_activity/funding/funding?id=' + id,
        })
      }
    },
    handle(e) {
      console.log(e)
      this.setData({
        index: e.currentTarget.dataset.index
      })
      this.triggerEvent('childIndex', this.data.index)
    }
  }
})